<?php
class MyDB{
	public static $conn;	
}
	
	function connectDB(){
		$dbHost = 'localhost';
		$dbUsername = 'root';
		$dbPassword = '';
		$dbName = 'webkhoa';
		MyDB::$conn = mysqli_connect($dbHost, $dbUsername, $dbPassword, $dbName);
	}
	
	function disconnectDB(){
		mysqli_close(MyDB::$conn);
	}
	
	function autoCommitOff(){
		mysqli_autocommit(MyDB::$conn,FALSE);
	}
	
	function commitTRAN(){
		return mysqli_commit(MyDB::$conn);
	}
	
	function getQueryArray($query){
		$arrayList = Array();
		if(MyDB::$conn){
			$result = mysqli_query(MyDB::$conn, $query);
			if(mysqli_num_rows($result) != 0){
				while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
					array_push($arrayList, $row);
				}
			}
			mysqli_free_result($result);
		}
		return $arrayList;
	}
	
	function getQueryObject($query){
		$row = null;
		if(MyDB::$conn){
			$result = mysqli_query(MyDB::$conn, $query);
			if(mysqli_num_rows($result) != 0){
				$row = mysqli_fetch_array($result, MYSQLI_ASSOC);
			}
			mysqli_free_result($result);
		}
		return $row;
	}
	
	function getQueryUpdate($query){
		mysqli_query(MyDB::$conn, $query);
	}
	
?>